package com.finance.scheduler.service;

import com.finance.scheduler.responsexml.PullLogistics;
import lombok.Data;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Data
public class PullResult{

        boolean error = false;

        List<PullLogistics> list = new ArrayList<PullLogistics>();

        public void add(PullLogistics pullLogistics){
            this.list.add(pullLogistics);
        }

        public void addAll(Collection<PullLogistics> list){
            this.list.addAll(list);
        }

        public void join(PullResult pullResult){
            this.error = this.error || pullResult.isError();
            if(CollectionUtils.isNotEmpty(pullResult.getList())) {
                this.list.addAll(pullResult.getList());
            }
        }
}